Make geocache a real class. (#968)
authortsteven4 <13596209+tsteven4@users.noreply.github.com>
Mon, 2 Jan 2023 17:30:56 +0000 (10:30 -0700)
committerGitHub <noreply@github.com>
Mon, 2 Jan 2023 17:30:56 +0000 (10:30 -0700)
24 files changed:
CMakeLists.txt
defs.h
duplicate.cc
duplicate.h
garmin.cc
geo.cc
geocache.cc [new file with mode: 0644]
geocache.h [new file with mode: 0644]
gpx.cc
gpx.h
html.cc
kml.cc
lowranceusr.cc
mkshort.cc
osm.cc
sort.cc
sort.h
text.cc
unicsv.cc
unicsv.h
util.cc
vcf.cc
waypt.cc
xcsv.cc

index 00536ca5ea3a21865a1e22ff3918c8168c5daad8..0c4448d50a589457356b42506f314ceb2b271aef 100644 (file)
@@ -87,6 +87,7 @@ set(ALL_FMTS ${MINIMAL_FMTS}
   garmin_txt.cc
   garmin_xt.cc
   gdb.cc
+  geocache.cc
   geojson.cc
   globalsat_sport.cc
   gpssim.cc
@@ -221,6 +222,7 @@ set(HEADERS
   gbser.h
   gbser_private.h
   gdb.h
+  geocache.h
   geojson.h
   globalsat_sport.h
   gpx.h
diff --git a/defs.h b/defs.h
index 03088026073756ca1a24b2d388e82d2306e082d3..fe74f4f741b03adc884de08601a270c1f201946b 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -39,6 +39,7 @@
 #include <Qt>                        // for CaseInsensitive
 #include <QtGlobal>                  // for QForeachContainer, qMakeForeachContainer, foreach, qint64
 
+#include "geocache.h"                // for Geocache
 #include "formspec.h"                // for FormatSpecificData
 #include "inifile.h"                 // for inifile_t
 #include "session.h"                 // for session_t
@@ -198,93 +199,6 @@ enum fix_type {
   fix_pps
 };
 
-enum status_type {
-  status_unknown=0,
-  status_true,
-  status_false
-};
-
-/*
- * Extended data if waypoint happens to represent a geocache.  This is
- * totally voluntary data...
- */
-
-enum geocache_type {
-  gt_unknown = 0,
-  gt_traditional,
-  gt_multi,
-  gt_virtual,
-  gt_letterbox,
-  gt_event,
-  gt_surprise,
-  gt_webcam,
-  gt_earth,
-  gt_locationless,
-  gt_benchmark, /* Extension to Groundspeak for GSAK */
-  gt_cito,
-  gt_ape,
-  gt_mega,
-  gt_wherigo
-};
-
-enum geocache_container {
-  gc_unknown = 0,
-  gc_micro,
-  gc_other,
-  gc_regular,
-  gc_large,
-  gc_virtual,
-  gc_small
-};
-
-class utf_string
-{
-public:
-  utf_string() = default;
-  utf_string(bool html, QString str) :
-    is_html{html},
-    utfstring{std::move(str)}
-  {}
-  bool is_html{false};
-  QString utfstring;
-};
-
-class geocache_data
-{
-public:
-  geocache_data() :
-    id(0),
-    type(gt_unknown),
-    container(gc_unknown),
-    diff(0),
-    terr(0),
-    is_archived(status_unknown),
-    is_available(status_unknown),
-    is_memberonly(status_unknown),
-    has_customcoords(status_unknown),
-    placer_id(0),
-    favorite_points(0)
-  {}
-  long long id; /* The decimal cache number */
-  geocache_type type:5;
-  geocache_container container:4;
-  unsigned int diff:6; /* (multiplied by ten internally) */
-  unsigned int terr:6; /* (likewise) */
-  status_type is_archived:2;
-  status_type is_available:2;
-  status_type is_memberonly:2;
-  status_type has_customcoords:2;
-  gpsbabel::DateTime exported;
-  gpsbabel::DateTime last_found;
-  QString placer; /* Placer name */
-  int placer_id; /* Placer id */
-  QString hint; /* all these UTF8, XML entities removed, May be not HTML. */
-  utf_string desc_short;
-  utf_string desc_long;
-  int favorite_points;
-  QString personal_note;
-};
-
 class gb_color
 {
 public:
@@ -422,7 +336,7 @@ struct bounds {
 class Waypoint
 {
 private:
-  static geocache_data empty_gc_data;
+  static Geocache empty_gc_data;
 
 public:
 
@@ -501,7 +415,7 @@ public:
   float power; /* watts, as measured by cyclists */
   float temperature; /* Degrees celsius */
   float odometer_distance; /* Meters */
-  geocache_data* gc_data;
+  Geocache* gc_data;
   FormatSpecificDataList fs;
   const session_t* session;    /* pointer to a session struct */
   void* extra_data;    /* Extra data added by, say, a filter. */
@@ -519,7 +433,7 @@ public:
   gpsbabel::DateTime GetCreationTime() const;
   void SetCreationTime(const gpsbabel::DateTime& t);
   void SetCreationTime(qint64 t, qint64 ms = 0);
-  geocache_data* AllocGCData();
+  Geocache* AllocGCData();
   int EmptyGCData() const;
 };
 
@@ -893,9 +807,6 @@ using ff_exit = void (*)();
 using ff_writeposn = void (*)(Waypoint*);
 using ff_readposn = Waypoint* (*)(posn_status*);
 
-geocache_type gs_mktype(const QString& t);
-geocache_container gs_mkcont(const QString& t);
-
 /*
  * All shortname functions take a shortname handle as the first arg.
  * This is an opaque pointer.  Callers must not fondle the contents of it.
@@ -1072,10 +983,7 @@ time_t mkgmtime(struct tm* t);
 bool gpsbabel_testmode();
 gpsbabel::DateTime current_time();
 QDateTime dotnet_time_to_qdatetime(long long dotnet);
-QString get_cache_icon(const Waypoint* waypointp);
-QString gs_get_cachetype(geocache_type t);
-QString gs_get_container(geocache_container t);
-QString strip_html(const utf_string*);
+QString strip_html(const QString& utfstring);
 QString strip_nastyhtml(const QString& in);
 QString convert_human_date_format(const char* human_datef);    /* "MM,YYYY,DD" -> "%m,%Y,%d" */
 QString convert_human_time_format(const char* human_timef);    /* "HH+mm+ss"   -> "%H+%M+%S" */
index 98f5d92d27d6cdc8f6ca7481c2e97e0c2386ad12..82f1eb929a198d193ccb269b2a0b37cbd3b529c2 100644 (file)
 
  */
 
-#include <algorithm>            // for stable_sort
-#include <cstdio>               // for snprintf
-#include <cstring>              // for memset, strncpy
+#include "duplicate.h"
+
+#include <algorithm>             // for stable_sort
+#include <cstdio>                // for snprintf
+#include <cstring>               // for memset, strncpy
 
-#include <QDateTime>            // for QDateTime
-#include <QtGlobal>             // for foreach
+#include <QDateTime>             // for QDateTime
 
 #include "defs.h"
-#include "duplicate.h"
-#include "src/core/datetime.h"  // for DateTime
+#include "geocache.h"            // for Geocache
+#include "src/core/datetime.h"   // for DateTime
 
 
 #if FILTERS_ENABLED
index f9ba5b44116904a12f54305ab567f95c584764da..0fd5f85cad64205928ab0ce70e219ece6626cab4 100644 (file)
@@ -22,7 +22,8 @@
 #ifndef DUPLICATE_H_INCLUDED_
 #define DUPLICATE_H_INCLUDED_
 
-#include <QVector>         // for QVector
+#include <QString>   // for QString
+#include <QVector>   // for QVector
 
 #include "defs.h"    // for ARGTYPE_BOOL, ARG_NOMINMAX, Waypoint (ptr only)
 #include "filter.h"  // for Filter
index a7c0c43a24a1d41a7854c5c01402ff43f021997c..14166c3eb130f81d2eb1ff50f1d305dd260c36d2 100644 (file)
--- a/garmin.cc
+++ b/garmin.cc
 
  */
 
-#include <cctype>               // for isalpha, toupper
-#include <climits>              // for INT_MAX
-#include <cmath>                // for atan2, floor, sqrt
-#include <csetjmp>              // for setjmp
-#include <cstdio>               // for fprintf, fflush, snprintf, snprintf
-#include <cstdlib>              // for strtol
-#include <cstring>              // for memcpy, strlen, strncpy, strchr
-#include <ctime>                // for time_t
-
-#include <QByteArray>           // for QByteArray
-#include <QChar>                // for QChar
-#include <QString>              // for QString
-#include <Qt>                   // for CaseInsensitive
-#include <QtGlobal>             // for qPrintable, foreach
+#include <cctype>                // for isalpha, toupper
+#include <climits>               // for INT_MAX
+#include <cmath>                 // for atan2, floor, sqrt
+#include <csetjmp>               // for setjmp
+#include <cstdio>                // for fprintf, fflush, snprintf, snprintf
+#include <cstdlib>               // for strtol
+#include <cstring>               // for memcpy, strlen, strncpy, strchr
+#include <ctime>                 // for time_t
+
+#include <QByteArray>            // for QByteArray
+#include <QChar>                 // for QChar
+#include <QString>               // for QString
+#include <QVector>               // for QVector
+#include <Qt>                    // for CaseInsensitive
+#include <QtGlobal>              // for qPrintable, foreach
 
 #include "defs.h"
-#include "cet_util.h"           // for cet_convert_init, cet_cs_vec_utf8
-#include "format.h"             // for Format
-#include "garmin_device_xml.h"  // for gdx_get_info, gdx_info, gdx_file, gdx_jmp_buf
-#include "garmin_fs.h"          // for garmin_fs_garmin_after_read, garmin_fs_garmin_before_write
-#include "garmin_tables.h"      // for gt_find_icon_number_from_desc, PCX, gt_find_desc_from_icon_number
-#include "grtcirc.h"            // for DEG
-#include "jeeps/gps.h"
-#include "jeeps/gpsserial.h"
-#include "src/core/datetime.h"  // for DateTime
-#include "vecs.h"               // for Vecs
+#include "cet_util.h"            // for cet_convert_init, cet_cs_vec_utf8
+#include "format.h"              // for Format
+#include "garmin_device_xml.h"   // for gdx_get_info, gdx_info, gdx_file, gdx_jmp_buf
+#include "garmin_fs.h"           // for garmin_fs_garmin_after_read, garmin_fs_garmin_before_write
+#include "garmin_tables.h"       // for gt_find_icon_number_from_desc, PCX, gt_find_desc_from_icon_number
+#include "geocache.h"            // for Geocache, Geocache::type_t, Geocache...
+#include "grtcirc.h"             // for DEG
+#include "jeeps/gpsapp.h"        // for GPS_Set_Baud_Rate, GPS_Init, GPS_Pre...
+#include "jeeps/gpscom.h"        // for GPS_Command_Get_Lap, GPS_Command_Get...
+#include "jeeps/gpsdevice.h"     // for gpsdevh
+#include "jeeps/gpsmem.h"        // for GPS_Track_Del, GPS_Way_Del, GPS_Pvt_Del
+#include "jeeps/gpsport.h"       // for int32
+#include "jeeps/gpsprot.h"       // for gps_waypt_type, gps_category_type
+#include "jeeps/gpssend.h"       // for GPS_SWay, GPS_PWay, GPS_STrack, GPS_...
+#include "jeeps/gpsserial.h"     // for DEFAULT_BAUD
+#include "jeeps/gpsutil.h"       // for GPS_User, GPS_Enable_Diagnose, GPS_E...
+#include "src/core/datetime.h"   // for DateTime
+#include "vecs.h"                // for Vecs
+
 
 #define MYNAME "GARMIN"
 static const char* portname;
@@ -798,25 +808,25 @@ static const char*
 get_gc_info(const Waypoint* wpt)
 {
   if (global_opts.smart_names) {
-    if (wpt->gc_data->type == gt_virtual) {
+    if (wpt->gc_data->type == Geocache::type_t::gt_virtual) {
       return  "V ";
     }
-    if (wpt->gc_data->type == gt_unknown) {
+    if (wpt->gc_data->type == Geocache::type_t::gt_unknown) {
       return  "? ";
     }
-    if (wpt->gc_data->type == gt_multi) {
+    if (wpt->gc_data->type == Geocache::type_t::gt_multi) {
       return  "Mlt ";
     }
-    if (wpt->gc_data->type == gt_earth) {
+    if (wpt->gc_data->type == Geocache::type_t::gt_earth) {
       return  "EC ";
     }
-    if (wpt->gc_data->type == gt_event) {
+    if (wpt->gc_data->type == Geocache::type_t::gt_event) {
       return  "Ev ";
     }
-    if (wpt->gc_data->container == gc_micro) {
+    if (wpt->gc_data->container == Geocache::container_t::gc_micro) {
       return  "M ";
     }
-    if (wpt->gc_data->container == gc_small) {
+    if (wpt->gc_data->container == Geocache::container_t::gc_small) {
       return  "S ";
     }
   }
@@ -895,8 +905,8 @@ waypoint_prepare()
     if (deficon) {
       icon = gt_find_icon_number_from_desc(deficon, PCX);
     } else {
-      if (!get_cache_icon(wpt).isEmpty()) {
-        icon = gt_find_icon_number_from_desc(get_cache_icon(wpt), PCX);
+      if (!wpt->gc_data->get_icon().isEmpty()) {
+        icon = gt_find_icon_number_from_desc(wpt->gc_data->get_icon(), PCX);
       } else {
         icon = gt_find_icon_number_from_desc(wpt->icon_descr, PCX);
       }
diff --git a/geo.cc b/geo.cc
index f9999afe15d3f0e9b4895f93b74491debab2f163..cc435e3cb8e8be6ead16e4b12db141f630270fab 100644 (file)
--- a/geo.cc
+++ b/geo.cc
@@ -29,6 +29,7 @@
 
 #include "defs.h"
 #include "gbfile.h"              // for gbfclose, gbfopen, gbfputs, gbfile
+#include "geocache.h"            // for Geocache, Geocache::container_t, Geo...
 #include "src/core/file.h"       // for File
 
 
@@ -50,7 +51,7 @@ QVector<arglist_t> geo_args = {
 static QXmlStreamReader reader;
 static QString geo_read_fname;
 
-static geocache_container wpt_container(const QString&);
+static Geocache::container_t wpt_container(const QString&);
 
 static void GeoReadLoc()
 {
@@ -126,34 +127,34 @@ geo_read()
   }
 }
 
-geocache_container wpt_container(const QString& args)
+Geocache::container_t wpt_container(const QString& args)
 {
-  geocache_container v;
+  Geocache::container_t v;
 
   switch (args.toInt()) {
   case 1:
-    v = gc_unknown;
+    v = Geocache::container_t::gc_unknown;
     break;
   case 2:
-    v = gc_micro;
+    v = Geocache::container_t::gc_micro;
     break;
   case 3:
-    v = gc_regular;
+    v = Geocache::container_t::gc_regular;
     break;
   case 4:
-    v = gc_large;
+    v = Geocache::container_t::gc_large;
     break;
   case 5:
-    v = gc_virtual;
+    v = Geocache::container_t::gc_virtual;
     break;
   case 6:
-    v = gc_other;
+    v = Geocache::container_t::gc_other;
     break;
   case 8:
-    v = gc_small;
+    v = Geocache::container_t::gc_small;
     break;
   default:
-    v = gc_unknown;
+    v = Geocache::container_t::gc_unknown;
     break;
   }
   return v;
@@ -219,25 +220,25 @@ geo_waypt_pr(const Waypoint* waypointp)
 
     int v = 1;
     switch (waypointp->gc_data->container) {
-    case gc_unknown:
+    case Geocache::container_t::gc_unknown:
       v = 1;
       break;
-    case gc_micro:
+    case Geocache::container_t::gc_micro:
       v = 2;
       break;
-    case gc_regular:
+    case Geocache::container_t::gc_regular:
       v = 3;
       break;
-    case gc_large:
+    case Geocache::container_t::gc_large:
       v = 4;
       break;
-    case gc_virtual:
+    case Geocache::container_t::gc_virtual:
       v = 5;
       break;
-    case gc_other:
+    case Geocache::container_t::gc_other:
       v = 6;
       break;
-    case gc_small:
+    case Geocache::container_t::gc_small:
       v = 8;
       break;
     default:
diff --git a/geocache.cc b/geocache.cc
new file mode 100644 (file)
index 0000000..c207283
--- /dev/null
@@ -0,0 +1,153 @@
+/*
+    Copyright (C) 2002-2023 Robert Lipe, robertlipe+source@gpsbabel.org
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+
+ */
+
+#include "geocache.h"
+
+#include <QString>               // for QString
+#include <QVector>               // for QVector
+#include <Qt>                    // for CaseInsensitive
+
+#include "defs.h"                // for strip_html, global_options, global_opts
+
+
+const QVector<Geocache::type_mapping> Geocache::type_map = {
+  {type_t::gt_traditional, "Traditional Cache" },
+  {type_t::gt_traditional, "Traditional" }, /* opencaching.de */
+  {type_t::gt_multi, "Multi-cache" },
+  {type_t::gt_multi, "Multi" }, /* opencaching.de */
+  {type_t::gt_virtual, "Virtual Cache" },
+  {type_t::gt_virtual, "Virtual" }, /* opencaching.de */
+  {type_t::gt_event, "Event Cache" },
+  {type_t::gt_event, "Event" }, /* opencaching.de */
+  {type_t::gt_webcam, "Webcam Cache" },
+  {type_t::gt_webcam, "Webcam" }, /* opencaching.de */
+  {type_t::gt_surprise, "Unknown Cache" },
+  {type_t::gt_earth, "Earthcache" },
+  {type_t::gt_earth, "Earth" }, /* opencaching.de */
+  {type_t::gt_cito, "Cache In Trash Out Event" },
+  {type_t::gt_letterbox, "Letterbox Hybrid" },
+  {type_t::gt_locationless, "Locationless (Reverse) Cache" },
+  {type_t::gt_ape, "Project APE Cache" },
+  {type_t::gt_mega, "Mega-Event Cache" },
+  {type_t::gt_wherigo, "Wherigo Cache" },
+
+  {type_t::gt_benchmark, "Benchmark" } /* Not Groundspeak; for GSAK  */
+};
+
+const QVector<Geocache::container_mapping> Geocache::container_map = {
+  {container_t::gc_other, "Unknown" },
+  {container_t::gc_other, "Other" }, /* Synonym on read. */
+  {container_t::gc_micro, "Micro" },
+  {container_t::gc_regular, "Regular" },
+  {container_t::gc_large, "Large" },
+  {container_t::gc_small, "Small" },
+  {container_t::gc_virtual, "Virtual" }
+};
+
+QString Geocache::UtfString::strip_html() const
+{
+  return is_html? ::strip_html(utf_string) : utf_string;
+}
+
+void Geocache::set_type(const QString& type_name)
+{
+  for (const auto& map_entry : type_map) {
+    if (!type_name.compare(map_entry.name,Qt::CaseInsensitive)) {
+      type = map_entry.type;
+      return;
+    }
+  }
+  type = type_t::gt_unknown;
+}
+
+QString Geocache::get_type() const
+{
+  for (const auto& map_entry : type_map) {
+    if (type == map_entry.type) {
+      return map_entry.name;
+    }
+  }
+  return "Unknown";
+}
+
+void Geocache::set_container(const QString& container_name)
+{
+  for (const auto& map_entry : container_map) {
+    if (!container_name.compare(map_entry.name,Qt::CaseInsensitive)) {
+      container = map_entry.container;
+      return;
+    }
+  }
+  container = container_t::gc_unknown;
+}
+
+QString Geocache::get_container() const
+{
+  for (const auto& map_entry : container_map) {
+    if (container == map_entry.container) {
+      return map_entry.name;
+    }
+  }
+  return "Unknown";
+}
+
+/*
+ * Return a QString that is suitable for icon lookup based on geocache
+ * attributes.  The strings used are those present in a GPX file from
+ * geocaching.com.  Thus we sort of make all the other formats do lookups
+ * based on these strings.
+ */
+QString Geocache::get_icon() const
+{
+  if (!global_opts.smart_icons) {
+    return nullptr;
+  }
+
+  /*
+   * For icons, type overwrites container.  So a multi-micro will
+   * get the icons for "multi".
+   */
+  switch (type) {
+  case type_t::gt_virtual:
+    return "Virtual cache";
+  case type_t::gt_multi:
+    return "Multi-Cache";
+  case type_t::gt_event:
+    return "Event Cache";
+  case type_t::gt_surprise:
+    return "Unknown Cache";
+  case type_t::gt_webcam:
+    return "Webcam Cache";
+  default:
+    break;
+  }
+
+  switch (container) {
+  case container_t::gc_micro:
+    return "Micro-Cache";
+  default:
+    break;
+  }
+
+  if (diff > 1) {
+    return "Geocache";
+  }
+
+  return nullptr;
+}
diff --git a/geocache.h b/geocache.h
new file mode 100644 (file)
index 0000000..25c4913
--- /dev/null
@@ -0,0 +1,146 @@
+/*
+    Copyright (C) 2002-2023 Robert Lipe, robertlipe+source@gpsbabel.org
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+
+ */
+#ifndef GEOCACHE_H_INCLUDED_
+#define GEOCACHE_H_INCLUDED_
+
+#include <QString>              // for QString
+#include <QVector>              // for QVector
+
+#include "src/core/datetime.h"  // for DateTime
+
+
+/*
+ * Extended data if waypoint happens to represent a geocache.  This is
+ * totally voluntary data...
+ */
+class Geocache
+{
+public:
+
+  /* Types */
+
+  enum class type_t {
+    gt_unknown = 0,
+    gt_traditional,
+    gt_multi,
+    gt_virtual,
+    gt_letterbox,
+    gt_event,
+    gt_surprise,
+    gt_webcam,
+    gt_earth,
+    gt_locationless,
+    gt_benchmark, /* Extension to Groundspeak for GSAK */
+    gt_cito,
+    gt_ape,
+    gt_mega,
+    gt_wherigo
+  };
+
+  enum class container_t {
+    gc_unknown = 0,
+    gc_micro,
+    gc_other,
+    gc_regular,
+    gc_large,
+    gc_virtual,
+    gc_small
+  };
+
+  enum class status_t {
+    gs_unknown = 0,
+    gs_true,
+    gs_false
+  };
+
+  class UtfString
+  {
+  public:
+
+    QString strip_html() const;
+
+    bool is_html{false};
+    QString utf_string;
+  };
+
+  /* Special Member Functions */
+
+  Geocache() :
+    id(0),
+    type(type_t::gt_unknown),
+    container(container_t::gc_unknown),
+    diff(0),
+    terr(0),
+    is_archived(status_t::gs_unknown),
+    is_available(status_t::gs_unknown),
+    is_memberonly(status_t::gs_unknown),
+    has_customcoords(status_t::gs_unknown),
+    placer_id(0),
+    favorite_points(0)
+  {}
+
+  /* Member Functions */
+
+  void set_type(const QString& type_name);
+  QString get_type() const;
+  void set_container(const QString& container_name);
+  QString get_container() const;
+  QString get_icon() const;
+
+  /* Data Members */
+
+  long long id; /* The decimal cache number */
+  type_t type:5;
+  container_t container:4;
+  unsigned int diff:6; /* (multiplied by ten internally) */
+  unsigned int terr:6; /* (likewise) */
+  status_t is_archived:2;
+  status_t is_available:2;
+  status_t is_memberonly:2;
+  status_t has_customcoords:2;
+  gpsbabel::DateTime exported;
+  gpsbabel::DateTime last_found;
+  QString placer; /* Placer name */
+  int placer_id; /* Placer id */
+  QString hint; /* all these UTF8, XML entities removed, May be not HTML. */
+  UtfString desc_short;
+  UtfString desc_long;
+  int favorite_points;
+  QString personal_note;
+
+private:
+
+  /* Types */
+
+  struct type_mapping {
+    type_t type;
+    QString name;
+  };
+
+  struct container_mapping {
+    container_t container;
+    QString name;
+  };
+
+  /* Constants */
+
+  static const QVector<type_mapping> type_map;
+  static const QVector<container_mapping> container_map;
+};
+#endif // GEOCACHE_H_INCLUDED_
diff --git a/gpx.cc b/gpx.cc
index e034de2549ef4fbc4cff523cb391fd898c590c3b..9bd27a10cf110b12c43dc999f68ee223cfe0c4d5 100644 (file)
--- a/gpx.cc
+++ b/gpx.cc
 
  */
 
-#include <cmath>                                   // for lround
-#include <cstdio>                                  // for sscanf
-#include <cstdlib>                                 // for strtod
-#include <cstring>                                 // for strchr, strncpy
-
-#include <QDate>                                   // for QDate
-#include <QDateTime>                               // for QDateTime
-#include <QHash>                                   // for QHash
-#include <QIODevice>                               // for QIODevice, operator|, QIODevice::ReadOnly, QIODevice::Text, QIODevice::WriteOnly
-#include <QLatin1Char>                             // for QLatin1Char
-#include <QLatin1String>                           // for QLatin1String
-#include <QString>                                 // for QString, QStringLiteral, operator+, operator==
-#include <QStringList>                             // for QStringList
-#include <QStringView>                             // for QStringView
-#include <QTime>                                   // for QTime
-#include <QVersionNumber>                          // for QVersionNumber
-#include <QXmlStreamAttribute>                     // for QXmlStreamAttribute
-#include <QXmlStreamAttributes>                    // for QXmlStreamAttributes
-#include <QXmlStreamNamespaceDeclaration>          // for QXmlStreamNamespaceDeclaration
-#include <QXmlStreamNamespaceDeclarations>         // for QXmlStreamNamespaceDeclarations
-#include <QXmlStreamReader>                        // for QXmlStreamReader, QXmlStreamReader::Characters, QXmlStreamReader::EndDocument, QXmlStreamReader::EndElement, QXmlStreamReader::Invalid, QXmlStreamReader::StartElement
-#include <Qt>                                      // for CaseInsensitive, UTC
-#include <QtGlobal>                                // for qAsConst, QAddConst<>::Type
+#include "gpx.h"
+
+#include <cmath>                            // for lround
+#include <cstdio>                           // for sscanf
+#include <cstring>                          // for strchr, strncpy
+
+#include <QByteArray>                       // for QByteArray
+#include <QDate>                            // for QDate
+#include <QDateTime>                        // for QDateTime
+#include <QHash>                            // for QHash
+#include <QIODevice>                        // for QIODevice, operator|, QIODevice::ReadOnly, QIODevice::Text, QIODevice::WriteOnly
+#include <QLatin1Char>                      // for QLatin1Char
+#include <QLatin1String>                    // for QLatin1String
+#include <QString>                          // for QString, QStringLiteral, operator+, operator==
+#include <QStringList>                      // for QStringList
+#include <QStringView>                      // for QStringView
+#include <QTime>                            // for QTime
+#include <QVersionNumber>                   // for QVersionNumber
+#include <QXmlStreamAttribute>              // for QXmlStreamAttribute
+#include <QXmlStreamAttributes>             // for QXmlStreamAttributes
+#include <QXmlStreamNamespaceDeclaration>   // for QXmlStreamNamespaceDeclaration
+#include <QXmlStreamNamespaceDeclarations>  // for QXmlStreamNamespaceDeclarations
+#include <QXmlStreamReader>                 // for QXmlStreamReader, QXmlStreamReader::Characters, QXmlStreamReader::EndDocument, QXmlStreamReader::EndElement, QXmlStreamReader::Invalid, QXmlStreamReader::StartElement
+#include <Qt>                               // for CaseInsensitive, UTC
+#include <QtGlobal>                         // for qAsConst, QAddConst<>::Type
 
 #include "defs.h"
-#include "gpx.h"
-#include "garmin_fs.h"                             // for garmin_fs_xml_convert, garmin_fs_xml_fprint, GMSD_FIND
-#include "garmin_tables.h"                         // for gt_color_index_by_rgb, gt_color_name, gt_color_value_by_name
-#include "src/core/datetime.h"                     // for DateTime
-#include "src/core/file.h"                         // for File
-#include "src/core/logging.h"                      // for Warning, Fatal
-#include "src/core/xmlstreamwriter.h"              // for XmlStreamWriter
-#include "src/core/xmltag.h"                       // for xml_tag, fs_xml, fs_xml_alloc, free_gpx_extras
+#include "garmin_fs.h"                      // for garmin_fs_xml_convert, garmin_fs_xml_fprint, GMSD_FIND
+#include "garmin_tables.h"                  // for gt_color_index_by_rgb, gt_color_name, gt_color_value_by_name
+#include "geocache.h"                       // for Geocache, Geocache::UtfSt...
+#include "src/core/datetime.h"              // for DateTime
+#include "src/core/file.h"                  // for File
+#include "src/core/logging.h"               // for Warning, Fatal
+#include "src/core/xmlstreamwriter.h"       // for XmlStreamWriter
+#include "src/core/xmltag.h"                // for xml_tag, fs_xml, fs_xml_alloc, free_gpx_extras
 
 
 #define MYNAME "GPX"
@@ -190,23 +192,23 @@ GpxFormat::tag_cache_desc(const QXmlStreamAttributes& attr)
 void
 GpxFormat::tag_gs_cache(const QXmlStreamAttributes& attr) const
 {
-  geocache_data* gc_data = wpt_tmp->AllocGCData();
+  Geocache* gc_data = wpt_tmp->AllocGCData();
 
   if (attr.hasAttribute(QLatin1String("id"))) {
     gc_data->id = attr.value(QLatin1String(QLatin1String("id"))).toLongLong();
   }
   if (attr.hasAttribute(QLatin1String("available"))) {
     if (attr.value(QLatin1String("available")).compare(QLatin1String("True"), Qt::CaseInsensitive) == 0) {
-      gc_data->is_available = status_true;
+      gc_data->is_available = Geocache::status_t::gs_true;
     } else if (attr.value(QLatin1String("available")).compare(QLatin1String("False"), Qt::CaseInsensitive) == 0) {
-      gc_data->is_available = status_false;
+      gc_data->is_available = Geocache::status_t::gs_false;
     }
   }
   if (attr.hasAttribute(QLatin1String("archived"))) {
     if (attr.value(QLatin1String("archived")).compare(QLatin1String("True"), Qt::CaseInsensitive) == 0) {
-      gc_data->is_archived = status_true;
+      gc_data->is_archived = Geocache::status_t::gs_true;
     } else if (attr.value(QLatin1String("archived")).compare(QLatin1String("False"), Qt::CaseInsensitive) == 0) {
-      gc_data->is_archived = status_false;
+      gc_data->is_archived = Geocache::status_t::gs_false;
     }
   }
 }
@@ -387,100 +389,6 @@ GpxFormat::gpx_start(QStringView el, const QXmlStreamAttributes& attr)
   }
 }
 
-struct
-  gs_type_mapping {
-  geocache_type type;
-  const char* name;
-} gs_type_map[] = {
-  { gt_traditional, "Traditional Cache" },
-  { gt_traditional, "Traditional" }, /* opencaching.de */
-  { gt_multi, "Multi-cache" },
-  { gt_multi, "Multi" }, /* opencaching.de */
-  { gt_virtual, "Virtual Cache" },
-  { gt_virtual, "Virtual" }, /* opencaching.de */
-  { gt_event, "Event Cache" },
-  { gt_event, "Event" }, /* opencaching.de */
-  { gt_webcam, "Webcam Cache" },
-  { gt_webcam, "Webcam" }, /* opencaching.de */
-  { gt_surprise, "Unknown Cache" },
-  { gt_earth, "Earthcache" },
-  { gt_earth, "Earth" }, /* opencaching.de */
-  { gt_cito, "Cache In Trash Out Event" },
-  { gt_letterbox, "Letterbox Hybrid" },
-  { gt_locationless, "Locationless (Reverse) Cache" },
-  { gt_ape, "Project APE Cache" },
-  { gt_mega, "Mega-Event Cache" },
-  { gt_wherigo, "Wherigo Cache" },
-
-  { gt_benchmark, "Benchmark" }, /* Not Groundspeak; for GSAK  */
-};
-
-struct
-  gs_container_mapping {
-  geocache_container type;
-  const char* name;
-} gs_container_map[] = {
-  { gc_other, "Unknown" },
-  { gc_other, "Other" }, /* Synonym on read. */
-  { gc_micro, "Micro" },
-  { gc_regular, "Regular" },
-  { gc_large, "Large" },
-  { gc_small, "Small" },
-  { gc_virtual, "Virtual" }
-};
-
-geocache_type
-gs_mktype(const QString& t)
-{
-  int sz = sizeof(gs_type_map) / sizeof(gs_type_map[0]);
-
-  for (int i = 0; i < sz; i++) {
-    if (!t.compare(gs_type_map[i].name,Qt::CaseInsensitive)) {
-      return gs_type_map[i].type;
-    }
-  }
-  return gt_unknown;
-}
-
-QString
-gs_get_cachetype(geocache_type t)
-{
-  int sz = sizeof(gs_type_map) / sizeof(gs_type_map[0]);
-
-  for (int i = 0; i < sz; i++) {
-    if (t == gs_type_map[i].type) {
-      return gs_type_map[i].name;
-    }
-  }
-  return "Unknown";
-}
-
-geocache_container
-gs_mkcont(const QString& t)
-{
-  int sz = sizeof(gs_container_map) / sizeof(gs_container_map[0]);
-
-  for (int i = 0; i < sz; i++) {
-    if (!t.compare(gs_container_map[i].name,Qt::CaseInsensitive)) {
-      return gs_container_map[i].type;
-    }
-  }
-  return gc_unknown;
-}
-
-QString
-gs_get_container(geocache_container t)
-{
-  int sz = sizeof(gs_container_map) / sizeof(gs_container_map[0]);
-
-  for (int i = 0; i < sz; i++) {
-    if (t == gs_container_map[i].type) {
-      return gs_container_map[i].name;
-    }
-  }
-  return "Unknown";
-}
-
 gpsbabel::DateTime
 xml_parse_time(const QString& dateTimeString)
 {
@@ -618,10 +526,10 @@ GpxFormat::gpx_end(QStringView /*unused*/)
     wpt_tmp->notes = cdatastr;
     break;
   case tt_cache_container:
-    wpt_tmp->AllocGCData()->container = gs_mkcont(cdatastr);
+    wpt_tmp->AllocGCData()->set_container(cdatastr);
     break;
   case tt_cache_type:
-    wpt_tmp->AllocGCData()->type = gs_mktype(cdatastr);
+    wpt_tmp->AllocGCData()->set_type(cdatastr);
     break;
   case tt_cache_difficulty:
     wpt_tmp->AllocGCData()->diff = cdatastr.toFloat() * 10;
@@ -630,15 +538,15 @@ GpxFormat::gpx_end(QStringView /*unused*/)
     wpt_tmp->AllocGCData()->hint = cdatastr;
     break;
   case tt_cache_desc_long: {
-    geocache_data* gc_data = wpt_tmp->AllocGCData();
+    Geocache* gc_data = wpt_tmp->AllocGCData();
     gc_data->desc_long.is_html = cache_descr_is_html;
-    gc_data->desc_long.utfstring = cdatastr;
+    gc_data->desc_long.utf_string = cdatastr;
   }
   break;
   case tt_cache_desc_short: {
-    geocache_data* gc_data = wpt_tmp->AllocGCData();
+    Geocache* gc_data = wpt_tmp->AllocGCData();
     gc_data->desc_short.is_html = cache_descr_is_html;
-    gc_data->desc_short.utfstring = cdatastr;
+    gc_data->desc_short.utf_string = cdatastr;
   }
   break;
   case tt_cache_terrain:
diff --git a/gpx.h b/gpx.h
index 98f68b0e7a9b2e4b48cf49fe245277cfefb564f2..98bcf872985b474cf6b63ba504094ef153584e94 100644 (file)
--- a/gpx.h
+++ b/gpx.h
 #ifndef GPX_H_INCLUDED_
 #define GPX_H_INCLUDED_
 
-#include <QHash>                        // for QHash
-#include <QString>                      // for QString
-#include <QStringList>                  // for QStringList
-#include <QStringView>                  // for QStringView
-#include <QVector>                      // for QVector
-#include <QVersionNumber>               // for QVersionNumber
-#include <QXmlStreamAttributes>         // for QXmlStreamAttributes
-#include <QXmlStreamReader>             // for QXmlStreamReader
+#include <QHash>                       // for QHash
+#include <QList>                       // for QList
+#include <QString>                     // for QString
+#include <QStringList>                 // for QStringList
+#include <QStringView>                 // for QStringView
+#include <QVector>                     // for QVector
+#include <QVersionNumber>              // for QVersionNumber
+#include <QXmlStreamAttributes>        // for QXmlStreamAttributes
+#include <QXmlStreamReader>            // for QXmlStreamReader
 
 #include "defs.h"
-#include "format.h"                     // for Format
-#include "formspec.h"                   // for FormatSpecificData
-#include "src/core/file.h"              // for File
-#include "src/core/xmlstreamwriter.h"   // for XmlStreamWriter
-#include "src/core/xmltag.h"            // for xml_tag
+#include "format.h"                    // for Format
+#include "formspec.h"                  // for FormatSpecificData
+#include "src/core/file.h"             // for File
+#include "src/core/xmlstreamwriter.h"  // for XmlStreamWriter
+#include "src/core/xmltag.h"           // for xml_tag
 
 
 class GpxFormat : public Format
diff --git a/html.cc b/html.cc
index 17ea6455321f677cf95b5ef366565fe50c014390..5ffe15b3619654a8b4e5cbf6a76300528883dd7c 100644 (file)
--- a/html.cc
+++ b/html.cc
@@ -32,6 +32,7 @@
 
 #include "defs.h"
 #include "formspec.h"              // for FormatSpecificDataList, kFsGpx
+#include "geocache.h"              // for Geocache, Geocache::UtfString
 #include "jeeps/gpsmath.h"         // for GPS_Math_WGS84_To_UTM_EN
 #include "src/core/datetime.h"     // for DateTime
 #include "src/core/textstream.h"   // for TextStream
@@ -114,8 +115,8 @@ HtmlFormat::html_disp(const Waypoint* wpt) const
               .arg((wpt->gc_data->diff%10) ? "&frac12;" : "")
               .arg((int)(wpt->gc_data->terr / 10))
               .arg((wpt->gc_data->terr%10) ? "&frac12;" : "");
-    *file_out << gs_get_cachetype(wpt->gc_data->type) << " / "
-              << gs_get_container(wpt->gc_data->container) << "</p>\n";
+    *file_out << wpt->gc_data->get_type() << " / "
+              << wpt->gc_data->get_container() << "</p>\n";
   }
   *file_out << "        </td>\n";
   *file_out << "      </tr>\n";
@@ -123,13 +124,13 @@ HtmlFormat::html_disp(const Waypoint* wpt) const
 
   *file_out << "      <tr>\n";
   *file_out << "        <td colspan=\"2\">\n";
-  if (!wpt->gc_data->desc_short.utfstring.isEmpty()) {
+  if (!wpt->gc_data->desc_short.utf_string.isEmpty()) {
     *file_out << "          <div><p class=\"gpsbabeldescshort\">"
-              << strip_nastyhtml(wpt->gc_data->desc_short.utfstring) << "</div>\n";
+              << strip_nastyhtml(wpt->gc_data->desc_short.utf_string) << "</div>\n";
   }
-  if (!wpt->gc_data->desc_long.utfstring.isEmpty()) {
+  if (!wpt->gc_data->desc_long.utf_string.isEmpty()) {
     *file_out << "          <div><p class=\"gpsbabeldesclong\">"
-              << strip_nastyhtml(wpt->gc_data->desc_long.utfstring) << "</div>\n";
+              << strip_nastyhtml(wpt->gc_data->desc_long.utf_string) << "</div>\n";
   }
   if (!wpt->gc_data->hint.isEmpty()) {
     QString hint;
diff --git a/kml.cc b/kml.cc
index 2e92632002d348da3d87ca07d8e4279982f756e0..0b8536038451bba1a1338ee4e100da6629e7e39c 100644 (file)
--- a/kml.cc
+++ b/kml.cc
 
  */
 
-#include <cctype>                       // for tolower, toupper
-#include <cmath>                        // for fabs
-#include <cstdio>                       // for sscanf, printf
-#include <cstdlib>                      // for strtod
-#include <cstring>                      // for strcmp
-#include <optional>                     // for optional
-#include <tuple>                        // for tuple, make_tuple
-
-#include <QByteArray>                   // for QByteArray
-#include <QChar>                        // for QChar
-#include <QDate>                        // for QDate
-#include <QDateTime>                    // for QDateTime
-#include <QFile>                        // for QFile
-#include <QIODevice>                    // for operator|, QIODevice, QIODevice::Text, QIODevice::WriteOnly
-#include <QList>                        // for QList
-#include <QString>                      // for QString, QStringLiteral, operator+, operator!=
-#include <QStringList>                  // for QStringList
-#include <QVector>                      // for QVector
-#include <QXmlStreamAttributes>         // for QXmlStreamAttributes
-#include <Qt>                           // for ISODate
-#include <QtGlobal>                     // for foreach, qint64, qRound, qPrintable
+#include "kml.h"
+
+#include <cctype>                      // for tolower, toupper
+#include <cmath>                       // for fabs
+#include <cstdio>                      // for sscanf, printf
+#include <cstdlib>                     // for strtod
+#include <cstring>                     // for strcmp
+#include <optional>                    // for optional
+#include <tuple>                       // for tuple, make_tuple
+
+#include <QByteArray>                  // for QByteArray
+#include <QChar>                       // for QChar
+#include <QDate>                       // for QDate
+#include <QDateTime>                   // for QDateTime
+#include <QFile>                       // for QFile
+#include <QIODevice>                   // for operator|, QIODevice, QIODevice::Text, QIODevice::WriteOnly
+#include <QList>                       // for QList
+#include <QString>                     // for QString, QStringLiteral, operator+, operator!=
+#include <QStringList>                 // for QStringList
+#include <QVector>                     // for QVector
+#include <QXmlStreamAttributes>        // for QXmlStreamAttributes
+#include <Qt>                          // for ISODate
+#include <QtGlobal>                    // for foreach, qint64, qRound, qPrintable
 
 #include "defs.h"
-#include "kml.h"
-#include "formspec.h"                   // for FsChainFind, kFsGpx
-#include "grtcirc.h"                    // for RAD, gcdist, radtometers
-#include "src/core/datetime.h"          // for DateTime
-#include "src/core/file.h"              // for File
-#include "src/core/logging.h"           // for Warning, Fatal
-#include "src/core/xmlstreamwriter.h"   // for XmlStreamWriter
-#include "src/core/xmltag.h"            // for xml_findfirst, xml_tag, fs_xml, xml_attribute, xml_findnext
-#include "units.h"                      // for fmt_setunits, fmt_speed, fmt_altitude, fmt_distance, units_aviation, units_metric, units_nautical, units_statute
-#include "xmlgeneric.h"                 // for cb_cdata, cb_end, cb_start, xg_callback, xg_string, xg_cb_type, xml_deinit, xml_ignore_tags, xml_init, xml_read, xg_tag_mapping
+#include "formspec.h"                  // for FsChainFind, kFsGpx
+#include "geocache.h"                  // for Geocache, Geocache::type_t
+#include "grtcirc.h"                   // for RAD, gcdist, radtometers
+#include "src/core/datetime.h"         // for DateTime
+#include "src/core/file.h"             // for File
+#include "src/core/logging.h"          // for Warning, Fatal
+#include "src/core/xmlstreamwriter.h"  // for XmlStreamWriter
+#include "src/core/xmltag.h"           // for xml_findfirst, xml_tag, fs_xml, xml_attribute, xml_findnext
+#include "units.h"                     // for fmt_setunits, fmt_speed, fmt_altitude, fmt_distance, units_aviation, units_metric, units_nautical, units_statute
+#include "xmlgeneric.h"                // for cb_cdata, cb_end, cb_start, xg_callback, xg_string, xg_cb_type, xml_deinit, xml_ignore_tags, xml_init, xml_read, xg_tag_mapping
 
 
 //  Icons provided and hosted by Google.  Used with permission.
@@ -1107,43 +1109,43 @@ QString KmlFormat::kml_lookup_gc_icon(const Waypoint* waypointp)
    * initializers...
    */
   switch (waypointp->gc_data->type) {
-  case gt_traditional:
+  case Geocache::type_t::gt_traditional:
     icon = "2.png";
     break;
-  case gt_multi:
+  case Geocache::type_t::gt_multi:
     icon = "3.png";
     break;
-  case gt_virtual:
+  case Geocache::type_t::gt_virtual:
     icon = "4.png";
     break;
-  case gt_letterbox:
+  case Geocache::type_t::gt_letterbox:
     icon = "5.png";
     break;
-  case gt_event:
+  case Geocache::type_t::gt_event:
     icon = "6.png";
     break;
-  case gt_ape:
+  case Geocache::type_t::gt_ape:
     icon = "7.png";
     break;
-  case gt_locationless:
+  case Geocache::type_t::gt_locationless:
     icon = "8.png";
     break; // No unique icon.
-  case gt_surprise:
+  case Geocache::type_t::gt_surprise:
     icon = "8.png";
     break;
-  case gt_webcam:
+  case Geocache::type_t::gt_webcam:
     icon = "11.png";
     break;
-  case gt_cito:
+  case Geocache::type_t::gt_cito:
     icon = "13.png";
     break;
-  case gt_earth:
+  case Geocache::type_t::gt_earth:
     icon = "earthcache.png";
     break;
-  case gt_mega:
+  case Geocache::type_t::gt_mega:
     icon = "453.png";
     break;
-  case gt_wherigo:
+  case Geocache::type_t::gt_wherigo:
     icon = "1858.png";
     break;
   default:
@@ -1159,22 +1161,22 @@ const char* KmlFormat::kml_lookup_gc_container(const Waypoint* waypointp)
   const char* cont;
 
   switch (waypointp->gc_data->container) {
-  case gc_micro:
+  case Geocache::container_t::gc_micro:
     cont="micro";
     break;
-  case gc_regular:
+  case Geocache::container_t::gc_regular:
     cont="regular";
     break;
-  case gc_large:
+  case Geocache::container_t::gc_large:
     cont="large";
     break;
-  case gc_small:
+  case Geocache::container_t::gc_small:
     cont="small";
     break;
-  case gc_virtual:
+  case Geocache::container_t::gc_virtual:
     cont="virtual";
     break;
-  case gc_other:
+  case Geocache::container_t::gc_other:
     cont="other";
     break;
   default:
@@ -1336,9 +1338,9 @@ void KmlFormat::kml_geocache_pr(const Waypoint* waypointp) const
 
   // Highlight any issues with the cache, such as temp unavail
   // or archived.
-  if (waypointp->gc_data->is_archived == status_true) {
+  if (waypointp->gc_data->is_archived == Geocache::status_t::gs_true) {
     issues = "&lt;font color=\"red\"&gt;This cache has been archived.&lt;/font&gt;&lt;br/&gt;\n";
-  } else if (waypointp->gc_data->is_available == status_false) {
+  } else if (waypointp->gc_data->is_available == Geocache::status_t::gs_false) {
     issues = "&lt;font color=\"red\"&gt;This cache is temporarily unavailable.&lt;/font&gt;&lt;br/&gt;\n";
   }
   kml_write_data_element("gc_issues", issues);
@@ -1346,10 +1348,10 @@ void KmlFormat::kml_geocache_pr(const Waypoint* waypointp) const
   kml_write_data_element("gc_lat", waypointp->latitude);
   kml_write_data_element("gc_lon", waypointp->longitude);
 
-  kml_write_data_element("gc_type", gs_get_cachetype(waypointp->gc_data->type));
+  kml_write_data_element("gc_type", waypointp->gc_data->get_type());
   kml_write_data_element("gc_icon", is);
-  kml_write_cdata_element("gc_short_desc", waypointp->gc_data->desc_short.utfstring);
-  kml_write_cdata_element("gc_long_desc", waypointp->gc_data->desc_long.utfstring);
+  kml_write_cdata_element("gc_short_desc", waypointp->gc_data->desc_short.utf_string);
+  kml_write_cdata_element("gc_long_desc", waypointp->gc_data->desc_long.utf_string);
   QString logs = kml_geocache_get_logs(waypointp);
   kml_write_cdata_element("gc_logs", logs);
 
index e7bb1d39b048a03d0d8d200c0913d0e93ed265ab..ece237a698a4dc383916cab34e7b5e312f27a6e8 100644 (file)
 
 */
 
-#include <cinttypes>              // for PRId64
-#include <cmath>                  // for M_PI, round, atan, exp, log, tan
-#include <cstdio>                 // for printf, sprintf, SEEK_CUR
-#include <cstdint>                // for int64_t
-#include <cstdlib>                // for abs
-#include <cstring>                // for strcmp, strlen
-
-#include <QByteArray>             // for QByteArray
-#include <QDate>                  // for QDate
-#include <QDateTime>              // for QDateTime
-#include <QLatin1String>          // for QLatin1String
-#include <QList>                  // for QList
-#include <QScopedPointer>         // for QScopedPointer
-#include <QString>                // for QString, operator+, operator==, operator!=
-#include <QTextCodec>             // for QTextCodec, QTextCodec::IgnoreHeader
-#include <QTextEncoder>           // for QTextEncoder
-#include <QTime>                  // for QTime
-#include <Qt>                     // for CaseInsensitive, UTC
-#include <QtGlobal>               // for qPrintable, uint, qAsConst, QAddConst<>::Type
+#include "lowranceusr.h"
+
+#include <cinttypes>            // for PRId64
+#include <cmath>                // for M_PI, round, atan, exp, log, tan
+#include <cstdio>               // for printf, sprintf, SEEK_CUR
+#include <cstdint>              // for int64_t
+#include <cstdlib>              // for abs
+#include <cstring>              // for strcmp, strlen
+
+#include <QByteArray>           // for QByteArray
+#include <QDate>                // for QDate
+#include <QDateTime>            // for QDateTime
+#include <QList>                // for QList
+#include <QScopedPointer>       // for QScopedPointer
+#include <QString>              // for QString, operator+, operator==, operator!=
+#include <QTextCodec>           // for QTextCodec, QTextCodec::IgnoreHeader
+#include <QTextEncoder>         // for QTextEncoder
+#include <QTime>                // for QTime
+#include <Qt>                   // for CaseInsensitive, UTC
+#include <QtGlobal>             // for qPrintable, uint, qAsConst, QAddConst<>::Type
 
 #include "defs.h"
-#include "lowranceusr.h"
-#include "formspec.h"             // for FsChainFind, FsChainAdd, kFsLowranceusr4, FormatSpecificData
-#include "gbfile.h"               // for gbfgetint32, gbfputint32, gbfputint16, gbfgetc, gbfgetint16, gbfwrite, gbfputc, gbfeof, gbfgetflt, gbfclose, gbfgetdbl, gbfopen_le, gbfputdbl, gbfputs, gbfile, gbfputflt, gbfread, gbfseek
-#include "src/core/datetime.h"    // for DateTime
-#include "src/core/logging.h"     // for Warning
+#include "formspec.h"           // for FsChainFind, FsChainAdd, kFsLowranceusr4, FormatSpecificData
+#include "gbfile.h"             // for gbfgetint32, gbfputint32, gbfputint16, gbfgetc, gbfgetint16, gbfwrite, gbfputc, gbfeof, gbfgetflt, gbfclose, gbfgetdbl, gbfopen_le, gbfputdbl, gbfputs, gbfile, gbfputflt, gbfread, gbfseek
+#include "geocache.h"           // for Geocache, Geocache::status_t, Geocach...
+#include "src/core/datetime.h"  // for DateTime
+#include "src/core/logging.h"   // for Warning
 
 
 /* from waypt.c, we need to iterate over waypoints when extracting routes */
@@ -1346,13 +1347,14 @@ LowranceusrFormat::lowranceusr_waypt_disp(const Waypoint* wpt) const
 
   gbfputint32(waypt_time, file_out);
 
-  if (!get_cache_icon(wpt).isEmpty() && wpt->icon_descr.compare(u"Geocache Found") == 0) {
-    SymbolId = lowranceusr_find_icon_number_from_desc(get_cache_icon(wpt));
+  if (!wpt->gc_data->get_icon().isEmpty() && wpt->icon_descr.compare(u"Geocache Found") == 0) {
+    SymbolId = lowranceusr_find_icon_number_from_desc(wpt->gc_data->get_icon());
   } else {
     SymbolId = lowranceusr_find_icon_number_from_desc(wpt->icon_descr);
   }
   /* If the waypoint is archived or disabled, use a "disabled" icon instead. */
-  if ((wpt->gc_data->is_archived==status_true) || (wpt->gc_data->is_available==status_false)) {
+  if ((wpt->gc_data->is_archived == Geocache::status_t::gs_true) ||
+      (wpt->gc_data->is_available == Geocache::status_t::gs_false)) {
     SymbolId = lowranceusr_find_icon_number_from_desc(DISABLED_CACHE_TXT);
   }
 
@@ -1407,11 +1409,11 @@ LowranceusrFormat::lowranceusr4_waypt_disp(const Waypoint* wpt)
   gbfputint32(2, file_out);
 
   int SymbolId, ColorId;
-  if (!get_cache_icon(wpt).isEmpty() && wpt->icon_descr.compare(u"Geocache Found") == 0) {
+  if (!wpt->gc_data->get_icon().isEmpty() && wpt->icon_descr.compare(u"Geocache Found") == 0) {
     if (writing_version == 4) {
       SymbolId = lowranceusr4_find_icon_number_from_desc(wpt->icon_descr);
     } else {
-      SymbolId = lowranceusr_find_icon_number_from_desc(get_cache_icon(wpt));
+      SymbolId = lowranceusr_find_icon_number_from_desc(wpt->gc_data->get_icon());
     }
     ColorId = 0; // default
   } else {
@@ -1423,7 +1425,8 @@ LowranceusrFormat::lowranceusr4_waypt_disp(const Waypoint* wpt)
     }
   }
   /* If the waypoint is archived or disabled, use a "disabled" icon instead. */
-  if ((wpt->gc_data->is_archived==status_true) || (wpt->gc_data->is_available==status_false)) {
+  if ((wpt->gc_data->is_archived == Geocache::status_t::gs_true) ||
+      (wpt->gc_data->is_available == Geocache::status_t::gs_false)) {
     SymbolId = lowranceusr_find_icon_number_from_desc(DISABLED_CACHE_TXT);
     ColorId = 0; // default
   }
index 34499a1d56fb41834720b1a64eef1affc88eff22..1d50860d887f4ef0495799eb0a930e5110f1f79f 100644 (file)
@@ -30,6 +30,7 @@
 #include <QtGlobal>    // for foreach
 
 #include "defs.h"
+#include "geocache.h"  // for Geocache
 
 
 #define MYNAME "mkshort"
diff --git a/osm.cc b/osm.cc
index 070b69f6f0a5bb3cf426aff2a6f156ffcfe25ac0..dbd44cd464c05446b7d9c7a8b097899341030b52 100644 (file)
--- a/osm.cc
+++ b/osm.cc
@@ -409,8 +409,7 @@ OsmFormat::osm_feature_symbol(const int ikey, const char* value) const
 QString
 OsmFormat::osm_strip_html(const QString& str)
 {
-  utf_string utf(true, str);
-  return strip_html(&utf);     // util.cc
+  return strip_html(str);      // util.cc
 }
 
 void
diff --git a/sort.cc b/sort.cc
index f3f182e89a336a1ae05fdd5484e6df96cc173d66..6c4afecd93b272b7d911e5cc1c17c8eebf5fa0c7 100644 (file)
--- a/sort.cc
+++ b/sort.cc
 
  */
 
+#include "sort.h"
+
 #include <QDateTime>            // for QDateTime
 #include <QString>              // for operator<, QString
 
 #include "defs.h"
+#include "geocache.h"           // for Geocache
 #include "src/core/datetime.h"  // for DateTime
-#include "sort.h"
+
 
 #if FILTERS_ENABLED
 #define MYNAME "sort"
diff --git a/sort.h b/sort.h
index 2c4ddf01a18ce9f70352acbfba4efee00e8fd121..07de160c7d0c890b00fc81a288bd5ae51526b806 100644 (file)
--- a/sort.h
+++ b/sort.h
@@ -22,7 +22,8 @@
 #ifndef SORT_H_INCLUDED_
 #define SORT_H_INCLUDED_
 
-#include <QVector>         // for QVector
+#include <QString>   // for QString
+#include <QVector>   // for QVector
 
 #include "defs.h"    // for ARGTYPE_BOOL, ARG_NOMINMAX, arglist_t, ARG_TERMI...
 #include "filter.h"  // for Filter
diff --git a/text.cc b/text.cc
index 2dd985160d79b10a3f04dbe32cc4925e01000f30..a0daa10ef0274503d5ca977ea8d3dd231f743e6f 100644 (file)
--- a/text.cc
+++ b/text.cc
@@ -32,6 +32,7 @@
 
 #include "defs.h"
 #include "formspec.h"              // for FormatSpecificDataList, kFsGpx
+#include "geocache.h"              // for Geocache, Geocache::UtfString
 #include "jeeps/gpsmath.h"         // for GPS_Math_WGS84_To_UTM_EN
 #include "src/core/datetime.h"     // for DateTime
 #include "src/core/textstream.h"   // for TextStream
@@ -102,17 +103,17 @@ TextFormat::text_disp(const Waypoint* wpt)
   }
   if (wpt->gc_data->terr) {
     *file_out << QStringLiteral(" - %1 / %2 - (%3%4 / %5%6)\n")
-              .arg(gs_get_cachetype(wpt->gc_data->type),
-                   gs_get_container(wpt->gc_data->container))
+              .arg(wpt->gc_data->get_type(),
+                   wpt->gc_data->get_container())
               .arg((int)(wpt->gc_data->diff / 10))
               .arg((wpt->gc_data->diff%10) ? ".5" : "")
               .arg((int)(wpt->gc_data->terr / 10))
               .arg((wpt->gc_data->terr%10) ? ".5" : "");
-    if (!wpt->gc_data->desc_short.utfstring.isEmpty()) {
-      *file_out << "\n" << strip_html(&wpt->gc_data->desc_short) << "\n";
+    if (!wpt->gc_data->desc_short.utf_string.isEmpty()) {
+      *file_out << "\n" << wpt->gc_data->desc_short.strip_html() << "\n";
     }
-    if (!wpt->gc_data->desc_long.utfstring.isEmpty()) {
-      *file_out << "\n" << strip_html(&wpt->gc_data->desc_long) << "\n";
+    if (!wpt->gc_data->desc_long.utf_string.isEmpty()) {
+      *file_out << "\n" << wpt->gc_data->desc_long.strip_html() << "\n";
     }
     if (!wpt->gc_data->hint.isEmpty()) {
       QString hint;
index ad6590c1f4f230b13cde82617556e080f39bc089..104406ef034192341edd164033abb8e99f954d6e 100644 (file)
--- a/unicsv.cc
+++ b/unicsv.cc
     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
 
+#include "unicsv.h"
+
 #include <cmath>                   // for fabs, lround
 #include <cstdio>                  // for NULL, sscanf
-#include <cstdint>
 #include <cstring>                 // for memset, strchr, strncpy
 #include <ctime>                   // for gmtime
 
@@ -30,7 +31,6 @@
 #include <QDateTime>               // for QDateTime
 #include <QIODevice>               // for QIODevice, QIODevice::ReadOnly, QIODevice::WriteOnly
 #include <QLatin1Char>             // for QLatin1Char
-#include <QLatin1String>           // for QLatin1String
 #include <QString>                 // for QString, operator!=, operator==
 #include <QStringList>             // for QStringList
 #include <QTextStream>             // for QTextStream, operator<<, qSetRealNumberPrecision, qSetFieldWidth, QTextStream::FixedNotation
 #include <QtGlobal>                // for qPrintable
 
 #include "defs.h"
-#include "unicsv.h"
 #include "csv_util.h"              // for csv_linesplit, human_to_dec
 #include "formspec.h"              // for FormatSpecificDataList
 #include "garmin_fs.h"             // for garmin_fs_flags_t, garmin_fs_t, GMSD_GET, GMSD_HAS, GMSD_SETQSTR, GMSD_FIND, garmin_fs_alloc
 #include "garmin_tables.h"         // for gt_lookup_datum_index, gt_get_mps_grid_longname, gt_lookup_grid_type
+#include "geocache.h"              // for Geocache, Geocache::status_t, Geoc...
 #include "jeeps/gpsmath.h"         // for GPS_Math_UKOSMap_To_WGS84_M, GPS_Math_EN_To_UKOSNG_Map, GPS_Math_Known_Datum_To_UTM_EN, GPS_Math_Known_Datum_To_WGS84_M, GPS_Math_Swiss_EN_To_WGS84, GPS_Math_UTM_EN_To_Known_Datum, GPS_Math_WGS84_To_Known_Datum_M, GPS_Math_WGS84_To_Swiss_EN, GPS_Math_WGS...
 #include "session.h"               // for session_t
 #include "src/core/datetime.h"     // for DateTime
@@ -321,20 +321,20 @@ UnicsvFormat::unicsv_parse_time(const QString& str, int* msec, time_t* date)
   return unicsv_parse_time(CSTR(str), msec, date);
 }
 
-status_type
+Geocache::status_t
 UnicsvFormat::unicsv_parse_status(const QString& str)
 {
   if (str.compare(u"true", Qt::CaseInsensitive) == 0 ||
       str.compare(u"yes", Qt::CaseInsensitive) == 0 ||
       str == '1') {
-    return status_true;
+    return Geocache::status_t::gs_true;
   }
   if (str.compare(u"false", Qt::CaseInsensitive) == 0 ||
       str.compare(u"no", Qt::CaseInsensitive) == 0 ||
       str == '0') {
-    return status_false;
+    return Geocache::status_t::gs_false;
   }
-  return status_unknown;
+  return Geocache::status_t::gs_unknown;
 }
 
 QDateTime
@@ -505,7 +505,7 @@ UnicsvFormat::unicsv_parse_one_line(const QString& ibuf)
   int src_datum = unicsv_datum_idx;
   int ns = 1;
   int ew = 1;
-  geocache_data* gc_data = nullptr;
+  Geocache* gc_data = nullptr;
   auto* wpt = new Waypoint;
   wpt->latitude = kUnicsvUnknown;
   wpt->longitude = kUnicsvUnknown;
@@ -902,10 +902,10 @@ UnicsvFormat::unicsv_parse_one_line(const QString& ibuf)
         }
         break;
       case fld_gc_type:
-        gc_data->type = gs_mktype(value);
+        gc_data->set_type(value);
         break;
       case fld_gc_container:
-        gc_data->container = gs_mkcont(value);
+        gc_data->set_container(value);
         break;
       case fld_gc_terr:
         gc_data->terr = value.toDouble() * 10;
@@ -1260,15 +1260,15 @@ UnicsvFormat::unicsv_waypt_enum_cb(const Waypoint* wpt)
   }
 
   if (! wpt->EmptyGCData()) {
-    const geocache_data* gc_data = wpt->gc_data;
+    const Geocache* gc_data = wpt->gc_data;
 
     if (gc_data->id) {
       gb_setbit(&unicsv_outp_flags, fld_gc_id);
     }
-    if (gc_data->type) {
+    if (gc_data->type != Geocache::type_t::gt_unknown) {
       gb_setbit(&unicsv_outp_flags, fld_gc_type);
     }
-    if (gc_data->container) {
+    if (gc_data->container != Geocache::container_t::gc_unknown) {
       gb_setbit(&unicsv_outp_flags, fld_gc_container);
     }
     if (gc_data->terr) {
@@ -1277,10 +1277,10 @@ UnicsvFormat::unicsv_waypt_enum_cb(const Waypoint* wpt)
     if (gc_data->diff) {
       gb_setbit(&unicsv_outp_flags, fld_gc_diff);
     }
-    if (gc_data->is_archived) {
+    if (gc_data->is_archived != Geocache::status_t::gs_unknown) {
       gb_setbit(&unicsv_outp_flags, fld_gc_is_archived);
     }
-    if (gc_data->is_available) {
+    if (gc_data->is_available != Geocache::status_t::gs_unknown) {
       gb_setbit(&unicsv_outp_flags, fld_gc_is_available);
     }
     if (gc_data->exported.isValid()) {
@@ -1305,7 +1305,7 @@ void
 UnicsvFormat::unicsv_waypt_disp_cb(const Waypoint* wpt)
 {
   double lat, lon, alt;
-  const geocache_data* gc_data = nullptr;
+  const Geocache* gc_data = nullptr;
   unicsv_waypt_ct++;
 
   QString shortname = wpt->shortname;
@@ -1618,14 +1618,14 @@ UnicsvFormat::unicsv_waypt_disp_cb(const Waypoint* wpt)
   }
   if FIELD_USED(fld_gc_type) {
     if (gc_data) {
-      unicsv_print_str(gs_get_cachetype(gc_data->type));
+      unicsv_print_str(gc_data->get_type());
     } else {
       *fout << unicsv_fieldsep;
     }
   }
   if FIELD_USED(fld_gc_container) {
     if (gc_data) {
-      unicsv_print_str(gs_get_container(gc_data->container));
+      unicsv_print_str(gc_data->get_container());
     } else {
       *fout << unicsv_fieldsep;
     }
@@ -1643,15 +1643,15 @@ UnicsvFormat::unicsv_waypt_disp_cb(const Waypoint* wpt)
     }
   }
   if FIELD_USED(fld_gc_is_archived) {
-    if (gc_data && gc_data->is_archived) {
-      unicsv_print_str((gc_data->is_archived == status_true) ? "True" : "False");
+    if (gc_data && (gc_data->is_archived != Geocache::status_t::gs_unknown)) {
+      unicsv_print_str((gc_data->is_archived == Geocache::status_t::gs_true) ? "True" : "False");
     } else {
       *fout << unicsv_fieldsep;
     }
   }
   if FIELD_USED(fld_gc_is_available) {
-    if (gc_data && gc_data->is_available) {
-      unicsv_print_str((gc_data->is_available == status_true) ? "True" : "False");
+    if (gc_data && (gc_data->is_available != Geocache::status_t::gs_unknown)) {
+      unicsv_print_str((gc_data->is_available == Geocache::status_t::gs_true) ? "True" : "False");
     } else {
       *fout << unicsv_fieldsep;
     }
index 1a0e249d8066bb35146a85be1de8c4485ff9b3bf..08dfa44660f47b199c342763763a5b5490522f49 100644 (file)
--- a/unicsv.h
+++ b/unicsv.h
@@ -30,6 +30,7 @@
 
 #include "defs.h"
 #include "format.h"               // for Format
+#include "geocache.h"             // for Geocache, Geocache::status_t
 #include "src/core/textstream.h"  // for TextStream
 
 
@@ -176,7 +177,7 @@ private:
   static time_t unicsv_parse_date(const char* str, int* consumed);
   static time_t unicsv_parse_time(const char* str, int* usec, time_t* date);
   static time_t unicsv_parse_time(const QString& str, int* msec, time_t* date);
-  static status_type unicsv_parse_status(const QString& str);
+  static Geocache::status_t unicsv_parse_status(const QString& str);
   QDateTime unicsv_adjust_time(time_t time, const time_t* date) const;
   static bool unicsv_compare_fields(const QString& s, const field_t* f);
   void unicsv_fondle_header(QString header);
diff --git a/util.cc b/util.cc
index a5887ab81533b8629b21b75cb68aed8a0c6fd1e1..643c86244be3b4db6d8533b0d3ba462c9cf26228 100644 (file)
--- a/util.cc
+++ b/util.cc
@@ -709,53 +709,6 @@ QDateTime dotnet_time_to_qdatetime(long long dotnet)
   return epoch.addMSecs(millisecs);
 }
 
-/*
- * Return a pointer to a constant string that is suitable for icon lookup
- * based on geocache attributes.   The strings used are those present in
- * a GPX file from geocaching.com.  Thus we sort of make all the other
- * formats do lookups based on these strings.
- */
-QString
-get_cache_icon(const Waypoint* waypointp)
-{
-  if (!global_opts.smart_icons) {
-    return nullptr;
-  }
-
-  /*
-   * For icons, type overwrites container.  So a multi-micro will
-   * get the icons for "multi".
-   */
-  switch (waypointp->gc_data->type) {
-  case gt_virtual:
-    return "Virtual cache";
-  case gt_multi:
-    return "Multi-Cache";
-  case gt_event:
-    return "Event Cache";
-  case gt_surprise:
-    return "Unknown Cache";
-  case gt_webcam:
-    return "Webcam Cache";
-  default:
-    break;
-  }
-
-  switch (waypointp->gc_data->container) {
-  case gc_micro:
-    return "Micro-Cache";
-    break;
-  default:
-    break;
-  }
-
-  if (waypointp->gc_data->diff > 1) {
-    return "Geocache";
-  }
-
-  return nullptr;
-}
-
 double
 endian_read_double(const void* ptr, int read_le)
 {
@@ -1251,31 +1204,26 @@ strip_nastyhtml(const QString& in)
  *  pleasant for a human reader.   Yes, this falls down in all kinds of
  *  ways such as spaces within the tags, etc.
  */
-QString
-strip_html(const utf_string* in)
+QString strip_html(const QString& utfstring)
 {
 #if 0
   // If we were willing to link core against QtGui (not out of the question)
   // we could just do...and either decide whether to add handling for [IMG]
   // or just say we don't do that any more.
   QTextDocument doc;
-  doc.setHtml(in->utfstring);
+  doc.setHtml(utfstring);
   return doc.toPlainText().simplified();
 #else
-  if (!in->is_html) {
-    return in->utfstring;
-  }
-
   char* out;
   char* instr;
   char tag[8];
   unsigned short int taglen = 0;
 
-  char* incopy = instr = xstrdup(in->utfstring);
+  char* incopy = instr = xstrdup(utfstring);
   /*
    * We only shorten, so just dupe the input buf for space.
    */
-  char* outstring = out = xstrdup(in->utfstring);
+  char* outstring = out = xstrdup(utfstring);
 
   tag[0] = 0;
   while (*instr) {
diff --git a/vcf.cc b/vcf.cc
index 209b4671368828660fefcf14610a63c809df6b95..fcc616eb0dce0acbacc60d57404f4b2896a7dd5c 100644 (file)
--- a/vcf.cc
+++ b/vcf.cc
     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
 
-#include <cmath>     // for fabs
-#include <cstdlib>   // for abs
+#include <cmath>       // for fabs
+#include <cstdlib>     // for abs
 
-#include <QString>   // for QString
-#include <QVector>   // for QVector
-#include <Qt>        // for CaseInsensitive
+#include <QString>     // for QString
+#include <QVector>     // for QVector
+#include <Qt>          // for CaseInsensitive
 
 #include "defs.h"
-#include "gbfile.h"  // for gbfprintf, gbfputs, gbfclose, gbfopen, gbfile
+#include "gbfile.h"    // for gbfprintf, gbfputs, gbfclose, gbfopen, gbfile
+#include "geocache.h"  // for Geocache, Geocache::UtfString
 
 
 static gbfile* file_out;
@@ -63,13 +64,13 @@ wr_deinit()
  * newlines as we go.
  */
 static void
-vcf_print_utf(const utf_string* s)
+vcf_print_utf(const Geocache::UtfString* s)
 {
-  if (!s) {
+  if (nullptr == s) {
     return;
   }
 
-  QString stripped_html = strip_html(s);
+  QString stripped_html = s->strip_html();
 
   stripped_html.replace("\n", "\\n", Qt::CaseInsensitive);
   stripped_html.replace("<p>", "\\n", Qt::CaseInsensitive);
index 68e2d6684ca0e0f07eb08b3d3fb5c27b4b984ff5..62836120bfe671019c9225d36afc9e351beb294e 100644 (file)
--- a/waypt.cc
+++ b/waypt.cc
@@ -37,6 +37,7 @@
 #include "defs.h"
 #include "formspec.h"           // for FormatSpecificDataList
 #include "garmin_fs.h"          // for garmin_ilink_t, garmin_fs_t
+#include "geocache.h"           // for Geocache
 #include "grtcirc.h"            // for RAD, gcdist, heading_true_degrees, radtometers
 #include "session.h"            // for curr_session, session_t
 #include "src/core/datetime.h"  // for DateTime
@@ -45,7 +46,7 @@
 
 WaypointList* global_waypoint_list;
 
-geocache_data Waypoint::empty_gc_data;
+Geocache Waypoint::empty_gc_data;
 static global_trait traits;
 
 const global_trait* get_traits()
@@ -449,7 +450,7 @@ Waypoint::Waypoint(const Waypoint& other) :
 {
   // deep copy geocache data unless it is the special static empty_gc_data.
   if (other.gc_data != &Waypoint::empty_gc_data) {
-    gc_data = new geocache_data(*other.gc_data);
+    gc_data = new Geocache(*other.gc_data);
   }
 
   // deep copy fs chain data.
@@ -501,7 +502,7 @@ Waypoint& Waypoint::operator=(const Waypoint& rhs)
     extra_data = rhs.extra_data;
     // deep copy geocache data unless it is the special static empty_gc_data.
     if (rhs.gc_data != &Waypoint::empty_gc_data) {
-      gc_data = new geocache_data(*rhs.gc_data);
+      gc_data = new Geocache(*rhs.gc_data);
     }
 
     // deep copy fs chain data.
@@ -567,11 +568,11 @@ Waypoint::SetCreationTime(qint64 t, qint64 ms)
   creation_time.setMSecsSinceEpoch((t * 1000) + ms);
 }
 
-geocache_data*
+Geocache*
 Waypoint::AllocGCData()
 {
   if (gc_data == &Waypoint::empty_gc_data) {
-    gc_data = new geocache_data;
+    gc_data = new Geocache;
   }
   return gc_data;
 }
diff --git a/xcsv.cc b/xcsv.cc
index 9425e56d824dc67e7bf2f8f466acaab267c9a13d..a7f2040a8a6fc11423a129823e456977cd7d1969 100644 (file)
--- a/xcsv.cc
+++ b/xcsv.cc
 
  */
 
-#include <cassert>                    // for assert
-#include <cctype>                     // for isdigit, tolower
-#include <cmath>                      // for fabs, pow
-#include <cstdio>                     // for snprintf, sscanf
-#include <cstdlib>                    // for strtod
-#include <cstring>                    // for strlen, strncmp, strcmp, memset
-#include <ctime>                      // for gmtime, localtime, time_t, mktime, strftime
-#include <optional>                   // for optional
-
-#include <QByteArray>                 // for QByteArray
-#include <QChar>                      // for QChar
-#include <QDate>                      // for QDate
-#include <QDateTime>                  // for QDateTime
-#include <QDebug>                     // for QDebug
-#include <QHash>                      // for QHash
-#include <QIODevice>                  // for QIODevice, operator|, QIODevice::ReadOnly, QIODevice::Text, QIODevice::WriteOnly
-#include <QList>                      // for QList
-#include <QRegularExpression>         // for QRegularExpression
-#include <QString>                    // for QString, operator+, operator==
-#include <QStringList>                // for QStringList
-#include <QTextStream>                // for QTextStream
-#include <QtGlobal>                   // for qAsConst, qRound, qPrintable
+#include "xcsv.h"
+
+#include <cctype>                  // for isdigit, tolower
+#include <cmath>                   // for fabs, pow
+#include <cstdio>                  // for snprintf, sscanf
+#include <cstdlib>                 // for strtod
+#include <cstring>                 // for strlen, strncmp, strcmp, memset
+#include <ctime>                   // for gmtime, localtime, time_t, mktime, strftime
+#include <optional>                // for optional
+
+#include <QByteArray>              // for QByteArray
+#include <QChar>                   // for QChar
+#include <QDate>                   // for QDate
+#include <QDateTime>               // for QDateTime
+#include <QDebug>                  // for QDebug
+#include <QHash>                   // for QHash
+#include <QIODevice>               // for QIODevice, operator|, QIODevice::ReadOnly, QIODevice::Text, QIODevice::WriteOnly
+#include <QList>                   // for QList
+#include <QRegularExpression>      // for QRegularExpression
+#include <QString>                 // for QString, operator+, operator==
+#include <QStringList>             // for QStringList
+#include <QTextStream>             // for QTextStream
+#include <QtGlobal>                // for qAsConst, qRound, qPrintable
 
 #include "defs.h"
-#include "csv_util.h"                 // for csv_stringtrim, dec_to_human, csv_stringclean, human_to_dec, ddmmdir_to_degrees, dec_to_intdeg, decdir_to_dec, intdeg_to_dec, csv_linesplit
-#include "formspec.h"                 // for FormatSpecificDataList
-#include "garmin_fs.h"                // for garmin_fs_t, garmin_fs_alloc
-#include "grtcirc.h"                  // for RAD, gcdist, radtometers
-#include "jeeps/gpsmath.h"            // for GPS_Math_WGS84_To_UTM_EN, GPS_Lookup_Datum_Index, GPS_Math_Known_Datum_To_WGS84_M, GPS_Math_UTM_EN_To_Known_Datum, GPS_Math_WGS84_To_Known_Datum_M, GPS_Math_WGS84_To_UKOSMap_M
-#include "jeeps/gpsport.h"            // for int32
-#include "session.h"                  // for session_t
-#include "src/core/datetime.h"        // for DateTime
-#include "src/core/logging.h"         // for FatalMsg
-#include "src/core/textstream.h"      // for TextStream
-#include "strptime.h"                 // for strptime
-#include "xcsv.h"
+#include "csv_util.h"              // for csv_stringtrim, dec_to_human, csv_stringclean, human_to_dec, ddmmdir_to_degrees, dec_to_intdeg, decdir_to_dec, intdeg_to_dec, csv_linesplit
+#include "formspec.h"              // for FormatSpecificDataList
+#include "garmin_fs.h"             // for garmin_fs_t, garmin_fs_alloc
+#include "geocache.h"              // for Geocache, Geocache::status_t, Geoc...
+#include "grtcirc.h"               // for RAD, gcdist, radtometers
+#include "jeeps/gpsmath.h"         // for GPS_Math_WGS84_To_UTM_EN, GPS_Lookup_Datum_Index, GPS_Math_Known_Datum_To_WGS84_M, GPS_Math_UTM_EN_To_Known_Datum, GPS_Math_WGS84_To_Known_Datum_M, GPS_Math_WGS84_To_UKOSMap_M
+#include "jeeps/gpsport.h"         // for int32
+#include "session.h"               // for session_t
+#include "src/core/datetime.h"     // for DateTime
+#include "src/core/logging.h"      // for FatalMsg
+#include "src/core/textstream.h"   // for TextStream
+#include "strptime.h"              // for strptime
 
 
 #if CSVFMTS_ENABLED
@@ -388,7 +389,7 @@ XcsvFormat::xcsv_parse_val(const QString& value, Waypoint* wpt, const XcsvStyle:
                            xcsv_parse_data* parse_data, const int line_no)
 {
   QString enclosure = "";
-  geocache_data* gc_data = nullptr;
+  Geocache* gc_data = nullptr;
 
   if (fmp.printfc.isNull()) {
     fatal(MYNAME ": xcsv style '%s' is missing format specifier", fmp.key.constData());
@@ -663,10 +664,10 @@ XcsvFormat::xcsv_parse_val(const QString& value, Waypoint* wpt, const XcsvStyle:
     break;
   case XcsvStyle::XT_GEOCACHE_TYPE:
     /* Geocache Type */
-    wpt->AllocGCData()->type = gs_mktype(value);
+    wpt->AllocGCData()->set_type(value);
     break;
   case XcsvStyle::XT_GEOCACHE_CONTAINER:
-    wpt->AllocGCData()->container = gs_mkcont(value);
+    wpt->AllocGCData()->set_container(value);
     break;
   case XcsvStyle::XT_GEOCACHE_HINT:
     wpt->AllocGCData()->hint = value.trimmed();
@@ -677,21 +678,21 @@ XcsvFormat::xcsv_parse_val(const QString& value, Waypoint* wpt, const XcsvStyle:
   case XcsvStyle::XT_GEOCACHE_ISAVAILABLE:
     gc_data = wpt->AllocGCData();
     if (value.trimmed().compare(u"False", Qt::CaseInsensitive) == 0) {
-      gc_data->is_available = status_false;
+      gc_data->is_available = Geocache::status_t::gs_false;
     } else if (value.trimmed().compare(u"True", Qt::CaseInsensitive) == 0) {
-      gc_data->is_available = status_true;
+      gc_data->is_available = Geocache::status_t::gs_true;
     } else {
-      gc_data->is_available = status_unknown;
+      gc_data->is_available = Geocache::status_t::gs_unknown;
     }
     break;
   case XcsvStyle::XT_GEOCACHE_ISARCHIVED:
     gc_data = wpt->AllocGCData();
     if (value.trimmed().compare(u"False", Qt::CaseInsensitive) == 0) {
-      gc_data->is_archived = status_false;
+      gc_data->is_archived = Geocache::status_t::gs_false;
     } else if (value.trimmed().compare(u"True", Qt::CaseInsensitive) == 0) {
-      gc_data->is_archived = status_true;
+      gc_data->is_archived = Geocache::status_t::gs_true;
     } else {
-      gc_data->is_archived = status_unknown;
+      gc_data->is_archived = Geocache::status_t::gs_unknown;
     }
     break;
 
@@ -1388,13 +1389,13 @@ XcsvFormat::xcsv_waypt_pr(const Waypoint* wpt)
       break;
     case XcsvStyle::XT_GEOCACHE_CONTAINER:
       /* Geocache Container */
-      buff = QString::asprintf(fmp.printfc.constData(), CSTR(gs_get_container(wpt->gc_data->container)));
-      field_is_unknown = wpt->gc_data->container == gc_unknown;
+      buff = QString::asprintf(fmp.printfc.constData(), CSTR(wpt->gc_data->get_container()));
+      field_is_unknown = wpt->gc_data->container == Geocache::container_t::gc_unknown;
       break;
     case XcsvStyle::XT_GEOCACHE_TYPE:
       /* Geocache Type */
-      buff = QString::asprintf(fmp.printfc.constData(), CSTR(gs_get_cachetype(wpt->gc_data->type)));
-      field_is_unknown = wpt->gc_data->type == gt_unknown;
+      buff = QString::asprintf(fmp.printfc.constData(), CSTR(wpt->gc_data->get_type()));
+      field_is_unknown = wpt->gc_data->type == Geocache::type_t::gt_unknown;
       break;
     case XcsvStyle::XT_GEOCACHE_HINT:
       buff = QString::asprintf(fmp.printfc.constData(), CSTR(wpt->gc_data->hint));
@@ -1405,18 +1406,18 @@ XcsvFormat::xcsv_waypt_pr(const Waypoint* wpt)
       field_is_unknown = !wpt->gc_data->placer.isEmpty();
       break;
     case XcsvStyle::XT_GEOCACHE_ISAVAILABLE:
-      if (wpt->gc_data->is_available == status_false) {
+      if (wpt->gc_data->is_available == Geocache::status_t::gs_false) {
         buff = QString::asprintf(fmp.printfc.constData(), "False");
-      } else if (wpt->gc_data->is_available == status_true) {
+      } else if (wpt->gc_data->is_available == Geocache::status_t::gs_true) {
         buff = QString::asprintf(fmp.printfc.constData(), "True");
       } else {
         buff = QString::asprintf(fmp.printfc.constData(), "Unknown");
       }
       break;
     case XcsvStyle::XT_GEOCACHE_ISARCHIVED:
-      if (wpt->gc_data->is_archived == status_false) {
+      if (wpt->gc_data->is_archived == Geocache::status_t::gs_false) {
         buff = QString::asprintf(fmp.printfc.constData(), "False");
-      } else if (wpt->gc_data->is_archived == status_true) {
+      } else if (wpt->gc_data->is_archived == Geocache::status_t::gs_true) {
         buff = QString::asprintf(fmp.printfc.constData(), "True");
       } else {
         buff = QString::asprintf(fmp.printfc.constData(), "Unknown");